
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>SPI协议 · STM32HAL系列教程</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Atonidas">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-lou/lou.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="CubeMX配置及主要函数.html" />
    
    
    <link rel="prev" href="../STM32串口/简单协议编写.html" />
    

    </head>
    <body>
         

<div class="book">
  <div class="header-inner">
    <!-- LOGO -->
    <div class="logo"></div>
    <span class="title"></span>

    <!-- Search -->
    
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>


    <!-- Nav -->
    <ul class="header-nav">
      <li>
        <a href="https://Gitee.com/atonidas" target="_blank">Gitee</a>
      </li>
    </ul>
  </div>

  <div class="book-summary">
    <div class="book-summary-title">文档目录</div>
     
    <nav role="navigation">


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../软件环境/">
            
                <a href="../软件环境/">
            
                    
                    软件环境
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../软件环境/VScode的使用.html">
            
                <a href="../软件环境/VScode的使用.html">
            
                    
                    VScode快速入门
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../软件环境/VSCode插件分享.html">
            
                <a href="../软件环境/VSCode插件分享.html">
            
                    
                    VScode插件分享
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../软件环境/CubeMX简介.html">
            
                <a href="../软件环境/CubeMX简介.html">
            
                    
                    CubeMX简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../软件环境/创建一个工程.html">
            
                <a href="../软件环境/创建一个工程.html">
            
                    
                    创建一个工程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../软件环境/Git版本管理.html">
            
                <a href="../软件环境/Git版本管理.html">
            
                    
                    Git版本管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../软件环境/创建一个快速开发模板.html">
            
                <a href="../软件环境/创建一个快速开发模板.html">
            
                    
                    创建一个快速开发模板
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../STM32的IO口/">
            
                <a href="../STM32的IO口/">
            
                    
                    STM32的IO口
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../STM32的IO口/点亮一个LED.html">
            
                <a href="../STM32的IO口/点亮一个LED.html">
            
                    
                    点亮一个LED
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../STM32的IO口/使用独立按键.html">
            
                <a href="../STM32的IO口/使用独立按键.html">
            
                    
                    使用独立按键
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../STM32中断/">
            
                <a href="../STM32中断/">
            
                    
                    STM32中断
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../STM32中断/CubeMX外部中断配置.html">
            
                <a href="../STM32中断/CubeMX外部中断配置.html">
            
                    
                    CubeMX外部中断配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../STM32中断/HAL库外部中断程序.html">
            
                <a href="../STM32中断/HAL库外部中断程序.html">
            
                    
                    HAL库外部中断程序
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../STM32定时器/">
            
                <a href="../STM32定时器/">
            
                    
                    STM32定时器
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../STM32定时器/定时器简单中断程序.html">
            
                <a href="../STM32定时器/定时器简单中断程序.html">
            
                    
                    定时器简单中断程序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../STM32定时器/硬件PWM输出.html">
            
                <a href="../STM32定时器/硬件PWM输出.html">
            
                    
                    硬件PWM输出
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../STM32定时器/DMA输出PWM控制WS2812.html">
            
                <a href="../STM32定时器/DMA输出PWM控制WS2812.html">
            
                    
                    DMA输出PWM控制WS2812
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../STM32串口/">
            
                <a href="../STM32串口/">
            
                    
                    STM32串口
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../STM32串口/串口发送及中断接收.html">
            
                <a href="../STM32串口/串口发送及中断接收.html">
            
                    
                    串口发送及中断接收
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../STM32串口/串口的格式化输出.html">
            
                <a href="../STM32串口/串口的格式化输出.html">
            
                    
                    串口的格式化输出
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../STM32串口/串口DMA传输.html">
            
                <a href="../STM32串口/串口DMA传输.html">
            
                    
                    串口DMA传输
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../STM32串口/简单协议编写.html">
            
                <a href="../STM32串口/简单协议编写.html">
            
                    
                    简单协议编写
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter active" data-level="1.7" data-path="./">
            
                <a href="./">
            
                    
                    SPI协议
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="CubeMX配置及主要函数.html">
            
                <a href="CubeMX配置及主要函数.html">
            
                    
                    CubeMX配置及主要参数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="OLED驱动移植.html">
            
                <a href="OLED驱动移植.html">
            
                    
                    OLED驱动移植
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="LVGL移植显示.html">
            
                <a href="LVGL移植显示.html">
            
                    
                    LVGL移植显示
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="Flash的使用及文件系统.html">
            
                <a href="Flash的使用及文件系统.html">
            
                    
                    Flash的使用及文件系统
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../ADC的使用/">
            
                <a href="../ADC的使用/">
            
                    
                    ADC的使用
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../ADC的使用/CubeMX中ADC配置概览.html">
            
                <a href="../ADC的使用/CubeMX中ADC配置概览.html">
            
                    
                    CubeMX中ADC配置概览
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../ADC的使用/查询阻塞方式.html">
            
                <a href="../ADC的使用/查询阻塞方式.html">
            
                    
                    查询阻塞方式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../ADC的使用/中断方式.html">
            
                <a href="../ADC的使用/中断方式.html">
            
                    
                    中断方式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../ADC的使用/DMA方式.html">
            
                <a href="../ADC的使用/DMA方式.html">
            
                    
                    DMA方式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.5" data-path="../ADC的使用/应用示例.html">
            
                <a href="../ADC的使用/应用示例.html">
            
                    
                    应用示例
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../其他代码整合搬运/">
            
                <a href="../其他代码整合搬运/">
            
                    
                    其他代码整合搬运
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../其他代码整合搬运/MultiButton.html">
            
                <a href="../其他代码整合搬运/MultiButton.html">
            
                    
                    MultiButton
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../其他代码整合搬运/EasyLogger.html">
            
                <a href="../其他代码整合搬运/EasyLogger.html">
            
                    
                    EasyLogger
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="../其他代码整合搬运/letter-shell.html">
            
                <a href="../其他代码整合搬运/letter-shell.html">
            
                    
                    letter-shell
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4" data-path="../其他代码整合搬运/EasyFlash.html">
            
                <a href="../其他代码整合搬运/EasyFlash.html">
            
                    
                    EasyFlash
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.5" data-path="../其他代码整合搬运/时间片调度.html">
            
                <a href="../其他代码整合搬运/时间片调度.html">
            
                    
                    时间片调度
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../加入我们/">
            
                <a href="../加入我们/">
            
                    
                    加入我们
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../加入我们/Gitbook环境.html">
            
                <a href="../加入我们/Gitbook环境.html">
            
                    
                    Gitbook环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../加入我们/Markdown语法简介.html">
            
                <a href="../加入我们/Markdown语法简介.html">
            
                    
                    Markdown语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="../加入我们/编辑器推荐.html">
            
                <a href="../加入我们/编辑器推荐.html">
            
                    
                    编辑器推荐
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.4" data-path="../加入我们/工程文件说明.html">
            
                <a href="../加入我们/工程文件说明.html">
            
                    
                    工程文件说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.5" data-path="../加入我们/提交注意事项.html">
            
                <a href="../加入我们/提交注意事项.html">
            
                    
                    提交注意事项
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>

</nav>
     
  </div>

  <!-- Content nav -->
  <div class="book-anchor">
    <div class="book-anchor-title"></div>

    <div class="book-anchor-body"></div>
  </div>

  <div class="book-body">
    
    <div class="body-inner">
       

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >SPI协议</a>
    </h1>
</div>



      <div class="page-wrapper" tabindex="-1" role="main">
        <div class="page-inner">
          
<div id="book-search-results">
    <div class="search-noresults">
    
          <section class="normal markdown-section">
             <p><span id="hidden-autonumber"></span></p>
<h1 class="article-title" id="stm32-spi">STM32-SPI</h1>

<h1 id="spi">SPI</h1>
<blockquote>
<p>SPI&#x534F;&#x8BAE;&#x3010;Serial Peripheral Interface&#x3011;&#x4E3A;&#x4E32;&#x884C;&#x5916;&#x56F4;&#x8BBE;&#x5907;&#x63A5;&#x53E3;&#xFF0C;&#x662F;&#x4E00;&#x79CD;&#x9AD8;&#x901F;&#x5168;&#x53CC;&#x5DE5;&#x7684;&#x540C;&#x6B65;&#x901A;&#x4FE1;&#x603B;&#x7EBF;&#x3002;&#x4E3B;&#x8981;&#x7528;&#x5728;MCU&#x4E0E;FLASH\ADC\LCD&#x7B49;&#x6A21;&#x5757;&#x4E4B;&#x95F4;&#x7684;&#x901A;&#x4FE1;&#x3002;<a href="https://blog.csdn.net/u014470361/article/details/79015712" target="_blank">&#x6587;&#x7AE0;&#x53C2;&#x8003;</a></p>
</blockquote>
<h2 id="spi&#x7684;&#x4FE1;&#x53F7;&#x7EBF;">SPI&#x7684;&#x4FE1;&#x53F7;&#x7EBF;</h2>
<p>SPI&#x901A;&#x5E38;&#x5305;&#x542B;4&#x6761;&#x603B;&#x7EBF;</p>
<ul>
<li><p><strong>SS&#xFF08;Slave Select&#xFF09;</strong>&#xFF1A;&#x7247;&#x9009;&#x4FE1;&#x53F7;&#x7EBF;&#xFF0C;&#x5F53;&#x6709;&#x591A;&#x4E2A;SPI &#x8BBE;&#x5907;&#x4E0E; MCU &#x76F8;&#x8FDE;&#x65F6;&#xFF0C;&#x6BCF;&#x4E2A;&#x8BBE;&#x5907;&#x7684;&#x8FD9;&#x4E2A;&#x7247;&#x9009;&#x4FE1;&#x53F7;&#x7EBF;&#x662F;&#x4E0E; MCU &#x5355;&#x72EC;&#x7684;&#x5F15;&#x811A;&#x76F8;&#x8FDE;&#x7684;&#xFF0C;&#x800C;&#x5176;&#x4ED6;&#x7684; SCK&#x3001;MOSI&#x3001;MISO &#x7EBF;&#x5219;&#x4E3A;&#x591A;&#x4E2A;&#x8BBE;&#x5907;&#x5E76;&#x8054;&#x5230;&#x76F8;&#x540C;&#x7684; SPI &#x603B;&#x7EBF;&#x4E0A;&#xFF0C;&#x4F4E;&#x7535;&#x5E73;&#x6709;&#x6548;</p>
</li>
<li><p><strong>SCK &#xFF08;Serial Clock&#xFF09;</strong>&#xFF1A;&#x65F6;&#x949F;&#x4FE1;&#x53F7;&#x7EBF;&#xFF0C;&#x7531;&#x4E3B;&#x901A;&#x4FE1;&#x8BBE;&#x5907;&#x4EA7;&#x751F;&#xFF0C;&#x4E0D;&#x540C;&#x7684;&#x8BBE;&#x5907;&#x652F;&#x6301;&#x7684;&#x65F6;&#x949F;&#x9891;&#x7387;&#x4E0D;&#x4E00;&#x6837;&#xFF0C;&#x5982; STM32 &#x7684; SPI &#x65F6;&#x949F;&#x9891;&#x7387;&#x6700;&#x5927;&#x4E3A; f PCLK /2</p>
</li>
<li><p><strong>MOSI &#xFF08;Master Output Slave Input&#xFF09;</strong>&#xFF1A;&#x4E3B;&#x8BBE;&#x5907;&#x8F93;&#x51FA; / &#x4ECE;&#x8BBE;&#x5907;&#x8F93;&#x5165;&#x5F15;&#x811A;&#x3002;&#x4E3B;&#x673A;&#x7684;&#x6570;&#x636E;&#x4ECE;&#x8FD9;&#x6761;&#x4FE1;&#x53F7;&#x7EBF;&#x8F93;&#x51FA;&#xFF0C;&#x4ECE;&#x673A;&#x7531;&#x8FD9;&#x6761;&#x4FE1;&#x53F7;&#x7EBF;&#x8BFB;&#x5165;&#x6570;&#x636E;&#xFF0C;&#x5373;&#x8FD9;&#x6761;&#x7EBF;&#x4E0A;&#x6570;&#x636E;&#x7684;&#x65B9;&#x5411;&#x4E3A;&#x4E3B;&#x673A;&#x5230;&#x4ECE;&#x673A;</p>
</li>
<li><p><strong>MISO&#xFF08;Master Input Slave Output&#xFF09;</strong>&#xFF1A;&#x4E3B;&#x8BBE;&#x5907;&#x8F93;&#x5165; / &#x4ECE;&#x8BBE;&#x5907;&#x8F93;&#x51FA;&#x5F15;&#x811A;&#x3002;&#x4E3B;&#x673A;&#x4ECE;&#x8FD9;&#x6761;&#x4FE1;&#x53F7;&#x7EBF;&#x8BFB;&#x5165;&#x6570;&#x636E;&#xFF0C;&#x4ECE;&#x673A;&#x7684;&#x6570;&#x636E;&#x5219;&#x7531;&#x8FD9;&#x6761;&#x4FE1;&#x53F7;&#x7EBF;&#x8F93;&#x51FA;&#xFF0C;&#x5373;&#x5728;&#x8FD9;&#x6761;&#x7EBF;&#x4E0A;&#x6570;&#x636E;&#x7684;&#x65B9;&#x5411;&#x4E3A;&#x4ECE;&#x673A;&#x5230;&#x4E3B;&#x673A;</p>
</li>
</ul>
<p>SPI&#x53EF;&#x4EE5;&#x4EE5;&#x4E0B;&#x56FE;&#x7684;&#x65B9;&#x5F0F;&#x8FDE;&#x63A5;&#x591A;&#x4E2A;&#x5916;&#x8BBE;&#x3002;
<img src="assets/SPI&#x8FDE;&#x7EBF;.png" alt="SPI&#x8FDE;&#x7EBF;">
&#x5176;&#x4E2D;SCK&#xFF0C;MOSI&#xFF0C;MISO&#x662F;&#x63A5;&#x5728;&#x4E00;&#x8D77;&#x7684;&#xFF0C;NSS&#x5206;&#x522B;&#x63A5;&#x5230;&#x4E0D;&#x540C;&#x7684;IO&#x7BA1;&#x811A;&#x63A7;&#x5236;&#x3002;&#x4E3B;&#x5668;&#x4EF6;&#x8981;&#x548C;&#x4ECE;&#x5668;&#x4EF6;&#x901A;&#x4FE1;&#x5C31;&#x5148;&#x62C9;&#x4F4E;&#x5BF9;&#x5E94;&#x4ECE;&#x5668;&#x4EF6;&#x7684;NSS&#x7BA1;&#x811A;&#x4F7F;&#x80FD;&#x3002;&#x9ED8;&#x8BA4;&#x72B6;&#x6001;IO1,IO2,IO3&#x5168;&#x4E3A;&#x9AD8;&#x7535;&#x5E73;&#xFF0C;&#x5F53;&#x4E3B;&#x5668;&#x4EF6;&#x548C;&#x4ECE;&#x5668;&#x4EF6;1&#x901A;&#x4FE1;&#x65F6;&#xFF0C;&#x62C9;&#x4F4E;IO1&#x7BA1;&#x811A;&#x4F7F;&#x80FD;&#x4ECE;&#x5668;&#x4EF6;1&#x3002;&#x800C;&#x4ECE;&#x5668;&#x4EF6;2,3&#x4E0D;&#x4F7F;&#x80FD;&#xFF0C;&#x4E0D;&#x4F5C;&#x54CD;&#x5E94;</p>
<h2 id="spi&#x7279;&#x6027;">SPI&#x7279;&#x6027;</h2>
<ul>
<li>&#x5355;&#x6B21;&#x4F20;&#x8F93;&#x53EF;&#x9009;&#x62E9;&#x4E3A; 8 &#x6216; 16 &#x4F4D;&#x3002;</li>
<li>&#x6CE2;&#x7279;&#x7387;&#x9884;&#x5206;&#x9891;&#x7CFB;&#x6570;(&#x6700;&#x5927;&#x4E3A; fPCLK/2) &#x3002;</li>
<li>&#x65F6;&#x949F;&#x6781;&#x6027;(CPOL)&#x548C;&#x76F8;&#x4F4D;(CPHA)&#x53EF;&#x7F16;&#x7A0B;&#x8BBE;&#x7F6E;&#x3002;</li>
<li>&#x6570;&#x636E;&#x987A;&#x5E8F;&#x7684;&#x4F20;&#x8F93;&#x987A;&#x5E8F;&#x53EF;&#x8FDB;&#x884C;&#x7F16;&#x7A0B;&#x9009;&#x62E9;&#xFF0C;MSB &#x5728;&#x524D;&#x6216; LSB &#x5728;&#x524D;&#x3002;</li>
<li>&#x53EF;&#x89E6;&#x53D1;&#x4E2D;&#x65AD;&#x7684;&#x4E13;&#x7528;&#x53D1;&#x9001;&#x548C;&#x63A5;&#x6536;&#x6807;&#x5FD7;&#x3002;</li>
<li>&#x53EF;&#x4EE5;&#x4F7F;&#x7528; DMA &#x8FDB;&#x884C;&#x6570;&#x636E;&#x4F20;&#x8F93;&#x64CD;&#x4F5C;&#x3002;<blockquote>
<p>&#x6CE8;&#xFF1A;MSB(Most Significant Bit)&#x662F;&#x201C;&#x6700;&#x9AD8;&#x6709;&#x6548;&#x4F4D;&#x201D;&#xFF0C;LSB(Least Significant Bit)&#x662F;&#x201C;&#x6700;&#x4F4E;&#x6709;&#x6548;&#x4F4D;&#x201D;</p>
</blockquote>
</li>
</ul>
<p>&#x4E0B;&#x4E3A;STM32&#x7684;SPI&#x6846;&#x67B6;&#x56FE;&#xFF1A;
<img src="assets/SPI&#x6846;&#x67B6;&#x56FE;.png" alt="SPI&#x6846;&#x67B6;&#x56FE;">
&#x5982;&#x4E0A;&#x56FE;&#xFF0C;MISO&#x6570;&#x636E;&#x7EBF;&#x63A5;&#x6536;&#x5230;&#x7684;&#x4FE1;&#x53F7;&#x7ECF;&#x79FB;&#x4F4D;&#x5BC4;&#x5B58;&#x5668;&#x5904;&#x7406;&#x540E;&#x628A;&#x6570;&#x636E;&#x8F6C;&#x79FB;&#x5230;&#x63A5;&#x6536;&#x7F13;&#x51B2;&#x533A;&#xFF0C;&#x7136;&#x540E;&#x8FD9;&#x4E2A;&#x6570;&#x636E;&#x5C31;&#x53EF;&#x4EE5;&#x7531;&#x6211;&#x4EEC;&#x7684;&#x8F6F;&#x4EF6;&#x4ECE;&#x63A5;&#x6536;&#x7F13;&#x51B2;&#x533A;&#x8BFB;&#x51FA;&#x4E86;&#x3002;</p>
<p>&#x5F53;&#x8981;&#x53D1;&#x9001;&#x6570;&#x636E;&#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x628A;&#x6570;&#x636E;&#x5199;&#x5165;&#x53D1;&#x9001;&#x7F13;&#x51B2;&#x533A;&#xFF0C;&#x786C;&#x4EF6;&#x5C06;&#x4F1A;&#x628A;&#x5B83;&#x7528;&#x79FB;&#x4F4D;&#x5BC4;&#x5B58;&#x5668;&#x5904;&#x7406;&#x540E;&#x8F93;&#x51FA;&#x5230; MOSI&#x6570;&#x636E;&#x7EBF;&#x3002;</p>
<p>SCK &#x7684;&#x65F6;&#x949F;&#x4FE1;&#x53F7;&#x5219;&#x7531;&#x6CE2;&#x7279;&#x7387;&#x53D1;&#x751F;&#x5668;&#x4EA7;&#x751F;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x6CE2;&#x7279;&#x7387;&#x63A7;&#x5236;&#x4F4D;&#xFF08;BR&#xFF09;&#x6765;&#x63A7;&#x5236;&#x5B83;&#x8F93;&#x51FA;&#x7684;&#x6CE2;&#x7279;&#x7387;&#x3002;</p>
<p>&#x63A7;&#x5236;&#x5BC4;&#x5B58;&#x5668; CR1&#x638C;&#x7BA1;&#x7740;&#x4E3B;&#x63A7;&#x5236;&#x7535;&#x8DEF;&#xFF0C;STM32&#x7684; SPI&#x6A21;&#x5757;&#x7684;&#x534F;&#x8BAE;&#x8BBE;&#x7F6E;&#xFF08;&#x65F6;&#x949F;&#x6781;&#x6027;&#x3001;&#x76F8;&#x4F4D;&#x7B49;&#xFF09;&#x5C31;&#x662F;&#x7531;&#x5B83;&#x6765;&#x5236;&#x5B9A;&#x7684;&#x3002;&#x800C;&#x63A7;&#x5236;&#x5BC4;&#x5B58;&#x5668; CR2&#x5219;&#x7528;&#x4E8E;&#x8BBE;&#x7F6E;&#x5404;&#x79CD;&#x4E2D;&#x65AD;&#x4F7F;&#x80FD;&#x3002;</p>
<p>&#x6700;&#x540E;&#x4E3A; NSS&#x5F15;&#x811A;&#xFF0C;&#x8FD9;&#x4E2A;&#x5F15;&#x811A;&#x626E;&#x6F14;&#x7740; SPI&#x534F;&#x8BAE;&#x4E2D;&#x7684;SS&#x7247;&#x9009;&#x4FE1;&#x53F7;&#x7EBF;&#x7684;&#x89D2;&#x8272;&#xFF0C;&#x5982;&#x679C;&#x6211;&#x4EEC;&#x628A; NSS&#x5F15;&#x811A;&#x914D;&#x7F6E;&#x4E3A;&#x786C;&#x4EF6;&#x81EA;&#x52A8;&#x63A7;&#x5236;&#xFF0C;SPI&#x6A21;&#x5757;&#x80FD;&#x591F;&#x81EA;&#x52A8;&#x5224;&#x522B;&#x5B83;&#x80FD;&#x5426;&#x6210;&#x4E3A; SPI&#x7684;&#x4E3B;&#x673A;&#xFF0C;&#x6216;&#x81EA;&#x52A8;&#x8FDB;&#x5165; SPI&#x4ECE;&#x673A;&#x6A21;&#x5F0F;&#x3002;&#x4F46;&#x5B9E;&#x9645;&#x4E0A;&#x6211;&#x4EEC;&#x7528;&#x5F97;&#x66F4;&#x591A;&#x7684;&#x662F;&#x7531;&#x8F6F;&#x4EF6;&#x63A7;&#x5236;&#x67D0;&#x4E9B; GPIO&#x5F15;&#x811A;&#x5355;&#x72EC;&#x4F5C;&#x4E3A;SS&#x4FE1;&#x53F7;&#xFF0C;&#x8FD9;&#x4E2A; GPIO&#x5F15;&#x811A;&#x53EF;&#x4EE5;&#x968F;&#x4FBF;&#x9009;&#x62E9;&#x3002;</p>
<h2 id="spi&#x65F6;&#x949F;&#x65F6;&#x5E8F;">SPI&#x65F6;&#x949F;&#x65F6;&#x5E8F;</h2>
<p>&#x6839;&#x636E;&#x65F6;&#x949F;&#x6781;&#x6027;&#xFF08;CPOL&#xFF09;&#x53CA;&#x76F8;&#x4F4D;&#xFF08;CPHA&#xFF09;&#x4E0D;&#x540C;&#xFF0C;SPI&#x6709;&#x56DB;&#x79CD;&#x5DE5;&#x4F5C;&#x6A21;&#x5F0F;&#x3002;</p>
<p><strong>&#x65F6;&#x949F;&#x6781;&#x6027;(CPOL)&#x5B9A;&#x4E49;&#x4E86;&#x65F6;&#x949F;&#x7A7A;&#x95F2;&#x72B6;&#x6001;&#x7535;&#x5E73;</strong></p>
<ul>
<li>CPOL=0&#x4E3A;&#x65F6;&#x949F;&#x7A7A;&#x95F2;&#x65F6;&#x4E3A;&#x4F4E;&#x7535;&#x5E73;</li>
<li>CPOL=1&#x4E3A;&#x65F6;&#x949F;&#x7A7A;&#x95F2;&#x65F6;&#x4E3A;&#x9AD8;&#x7535;&#x5E73;</li>
</ul>
<p><strong>&#x65F6;&#x949F;&#x76F8;&#x4F4D;(CPHA)&#x5B9A;&#x4E49;&#x6570;&#x636E;&#x7684;&#x91C7;&#x96C6;&#x65F6;&#x95F4;</strong></p>
<ul>
<li>CPHA=0:&#x5728;&#x65F6;&#x949F;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x8DF3;&#x53D8;&#x6CBF;&#xFF08;&#x4E0A;&#x5347;&#x6CBF;&#x6216;&#x4E0B;&#x964D;&#x6CBF;&#xFF09;&#x8FDB;&#x884C;&#x6570;&#x636E;&#x91C7;&#x6837;&#x3002;</li>
<li>CPHA=1:&#x5728;&#x65F6;&#x949F;&#x7684;&#x7B2C;&#x4E8C;&#x4E2A;&#x8DF3;&#x53D8;&#x6CBF;&#xFF08;&#x4E0A;&#x5347;&#x6CBF;&#x6216;&#x4E0B;&#x964D;&#x6CBF;&#xFF09;&#x8FDB;&#x884C;&#x6570;&#x636E;&#x91C7;&#x6837;&#x3002;</li>
</ul>
<p>&#x5177;&#x4F53;&#x65F6;&#x5E8F;&#x5982;&#x4E0B;&#x56FE;&#x6240;&#x793A;
<img src="assets/SPI&#x65F6;&#x5E8F;.png" alt="SPI&#x65F6;&#x5E8F;"></p>
<h2 id="&#x6559;&#x7A0B;&#x5206;&#x5E03;">&#x6559;&#x7A0B;&#x5206;&#x5E03;</h2>
<ul>
<li><a href="CubeMX&#x914D;&#x7F6E;&#x53CA;&#x4E3B;&#x8981;&#x51FD;&#x6570;.html">CubeMX&#x914D;&#x7F6E;&#x53CA;&#x4E3B;&#x8981;&#x51FD;&#x6570;</a></li>
<li><a href="OLED&#x9A71;&#x52A8;&#x79FB;&#x690D;.html">OLED&#x9A71;&#x52A8;&#x79FB;&#x690D;</a></li>
<li><a href="LVGL&#x79FB;&#x690D;&#x663E;&#x793A;.html">LVGL&#x79FB;&#x690D;&#x663E;&#x793A;</a></li>
<li><a href="Flash&#x7684;&#x4F7F;&#x7528;&#x53CA;&#x6587;&#x4EF6;&#x7CFB;&#x7EDF;.html">Flash&#x7684;&#x4F7F;&#x7528;&#x53CA;&#x6587;&#x4EF6;&#x7CFB;&#x7EDF;</a></li>
</ul>
 
          </section>
          
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>
 
        </div>
      </div>
      
    </div>

     
    <a
      href="../STM32串口/简单协议编写.html"
      class="
        navigation navigation-prev
        
      "
      aria-label="Previous page: 简单协议编写"
    >
      <i class="fa fa-angle-left"></i>
    </a>
     
    <a
      href="CubeMX配置及主要函数.html"
      class="
        navigation navigation-next
        
      "
      aria-label="Next page: CubeMX配置及主要参数"
    >
      <i class="fa fa-angle-right"></i>
    </a>
      
  </div>
  <script>
    function showModal() {
      document.getElementsByClassName("mask")[0].style.display = "block";
      document.getElementsByClassName("donate-modal")[0].style.display =
        "block";
    }
    // 切换赞赏码
    function showDonateImg(num) {
      let alipay = "";
      let wxpay = ""
      if(num){
        wxpay = "hidden"
      }else{
        alipay = "hidden"
      }
      document.getElementById("wxpay-code").hidden = wxpay;
      document.getElementById("alipay-code").hidden = alipay;
      document.getElementsByName("pay-way")[num].checked = "checked";
    }

    // 关闭赞赏框
    function closeDonateModal() {
      document.getElementsByClassName("mask")[0].style.display = "none";
      document.getElementsByClassName("donate-modal")[0].style.display = "none";
    }

    var gitbook = gitbook || [];
    gitbook.push(function () {
      gitbook.page.hasChanged({"page":{"title":"SPI协议","level":"1.7","depth":1,"next":{"title":"CubeMX配置及主要参数","level":"1.7.1","depth":2,"path":"SPI协议/CubeMX配置及主要函数.md","ref":"./SPI协议/CubeMX配置及主要函数.md","articles":[]},"previous":{"title":"简单协议编写","level":"1.6.4","depth":2,"path":"STM32串口/简单协议编写.md","ref":"./STM32串口/简单协议编写.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-lunr","-sharing","-search","-favicon","-code","expandable-chapters","theme-lou","back-to-top-button","search-pro","livereload"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"livereload":{},"search-pro":{},"code":{"copyButtons":true},"theme-lou":{"hide-elements":[".summary .gitbook-link"],"color":"#8abcd1","copyright":{"author":"Atonidas"},"forbidCopy":false,"logo":"assets/logo.png","search-placeholder":"查找关键内容","copyrightLogo":"assets/copyright.png","favicon":"assets/favicon.ico","autoNumber":3},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"back-to-top-button":{},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{}},"theme":"default","author":"Atonidas","lang":"zh-cn","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{"themeLou":{"nav":[{"target":"_blank","url":"https://Gitee.com/atonidas","name":"Gitee"}]}},"title":"STM32HAL系列教程","gitbook":"*","description":"Gitbook电子书示例项目"},"file":{"path":"SPI协议/README.md","mtime":"2023-04-04T06:18:13.026Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2023-09-13T00:50:24.020Z"},"basePath":"..","book":{"language":""}});
    });
  </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-lou/lou.js"></script>
        
    

    </body>
</html>

